package zouran.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Min;
import java.time.LocalDateTime;

/**
 * Author：zouran
 * Date：2023/3/31  23:15
 * Description:condition class
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SelectCondition {
    private String name = null;
    @Range(min = 0, max = 180)
    private Double east;
    @Range(min = 0, max = 90)
    private Double south;
    @Range(min = 0, max = 180)
    private Double west;
    @Range(min = 0, max = 90)
    private Double north;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime start;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime end;
    @Range(min = 0, max = 10)
    private Double min;
    @Range(min = 0, max = 10)
    private Double max;
    @Range(min = 1, max = 80)
    private Integer limit = 10;
    @Min(1)
    private Integer page = 1;

    public Integer getPage() {
        return (page - 1) * this.limit;
    }
}
